#!/bin/bash

# 容器和镜像名字
CONTAINER_NAME=app-container
IMAGE_NAME=app-image

echo ">>> 停止正在运行的容器（如果有）..."
docker stop $CONTAINER_NAME 2>/dev/null || true

echo ">>> 删除旧容器（如果有）..."
docker rm $CONTAINER_NAME 2>/dev/null || true

echo ">>> 构建镜像..."
docker build -t $IMAGE_NAME .

echo ">>> 运行容器..."
docker run -d --name $CONTAINER_NAME -p 8080:8080 -v /root/logs:/app/logs  $IMAGE_NAME

docker logs -f $CONTAINER_NAME
